<template>
    <div>
      <p>姓名：<input type="text" v-model="name"></p>
      <p>手机号码：<input type="number" v-model="num" style="width: 20px">&ensp;<input type="text" v-model="phone"></p>
      <p><button @click="add">提交</button></p>
    </div>
</template>

<script>
    export default {
      data(){
        return{
          num:86,
          user:'',
          phone:'',
          name:'',
          tid:this.$route.params.tid,
          pid:this.$route.params.pid,
          uid:sessionStorage.getItem('user_id')
        }
      },
      methods:{
        add(){
          if(!(/^1[3456789]\d{9}$/.test(this.phone))){
              alert('号码输入有误')
          }else {
          let form_data=new FormData()
          form_data.append('title',this.tid)
          form_data.append('price',this.pid)
          form_data.append('phone',this.phone)
          form_data.append('member',this.uid)
          form_data.append('name',this.name)
          axios({
            url:'http://127.0.0.1:8000/app02/addorder/',
            method:'post',
            data:form_data
          }).then(res=>{
            console.log(res)
          })
          }
      }}
  }
</script>

<style scoped>

</style>